package algorithm.leetcode;

import algorithm.templates.TreeNode;

public class NO104_二叉树的最大深度 {
    static class Solution {
        int maxDepth = 0;

        public int maxDepth(TreeNode root) {
            findMaxDepth(root, 0);
            return maxDepth;
        }

        private void findMaxDepth(TreeNode root, int curDepth) {
            if (root == null) {
                if (curDepth > maxDepth)
                    maxDepth = curDepth;
                return;
            }

            findMaxDepth(root.left, curDepth + 1);
            findMaxDepth(root.right, curDepth + 1);
        }
    }
}
